From: Ori Livneh Date: Thu, 13 Aug 2015 04:40:49 +0000 (-0700) Subject: MessageCache: derive the hash from the cache contents X-Git-Tag: 1.31.0-rc.0~10420 X-Git-Url: http://git.cyclocoop.org/%28%5B%5E/404?a=commitdiff_plain;h=6147de1182101903cf24259d61ec6ea34b907bf3;p=lhc%2Fweb%2Fwiklou.git MessageCache: derive the hash from the cache contents Follow-up for I020617d, where I got this wrong. It is probable that multiple application servers will try to build a local cache at the same time, in which case they will cause the cache key to thrash. It is necessary that two application servers building a local cache from the database generate the same hash for a given set of messages. Change-Id: Ieeefc2094a83be9401c466bec859c1588ddfbcdf --- diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index 304c4f2192..3f60d8c0c5 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -530,7 +530,8 @@ class MessageCache { } $cache['VERSION'] = MSG_CACHE_VERSION; - $cache['HASH'] = wfRandomString( 8 ); + ksort( $cache ); + $cache['HASH'] = md5( serialize( $cache ) ); $cache['EXPIRY'] = wfTimestamp( TS_MW, time() + $this->mExpiry ); return $cache;